package a66weding.com.jiehuntong.pager;

import android.app.Activity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import a66weding.com.jiehuntong.R;
import a66weding.com.jiehuntong.application.DataWareHourse;
import a66weding.com.jiehuntong.beans.CommonResultBean;
import a66weding.com.jiehuntong.beans.ErrorBean;
import a66weding.com.jiehuntong.beans.GuestsseatBean;
import a66weding.com.jiehuntong.beans.HttpRequestBean;
import a66weding.com.jiehuntong.beans.SuccessBean;
import a66weding.com.jiehuntong.beans.User;
import a66weding.com.jiehuntong.common.utils.CUtils;
import a66weding.com.jiehuntong.http.OnNetResultListener;
import a66weding.com.jiehuntong.http.RequestCode;
import a66weding.com.jiehuntong.http.UrlDealUtil;
import a66weding.com.jiehuntong.http.XutilHttp;

/**
 * Created by admin on 2016/6/1.
 */
public class Tools_AddGuesPager extends BasePager implements View.OnClickListener, OnNetResultListener {


    private TextView tvLeft, tvCenter, tvRight;
    private EditText tablenameEt, messageEt;
    private LinearLayout backLl;
    private String mobileNum;
    private Button overBtn;
    private EditText tablename_et, message_et;

    public Tools_AddGuesPager(Activity activity) {
        super(activity);
    }

    @Override
    protected View getView() {
        View myBodyView = View.inflate(mActivity, R.layout.activity_tools_addguestsseat, null);
        tablenameEt = (EditText) myBodyView.findViewById(R.id.input_tablename_edittext);
        messageEt = (EditText) myBodyView.findViewById(R.id.input_message_edittext);
        overBtn = (Button) myBodyView.findViewById(R.id.addhues_over_btn);
        backLl = (LinearLayout) myBodyView.findViewById(R.id.llay_toolsheader_back);

        tablename_et = (EditText) myBodyView.findViewById(R.id.input_tablename_edittext);
        message_et = (EditText) myBodyView.findViewById(R.id.input_message_edittext);

        tvLeft = (TextView) myBodyView.findViewById(R.id.headleft_title_tv);
        tvCenter = (TextView) myBodyView.findViewById(R.id.headcenter_title_tv);
        tvRight = (TextView) myBodyView.findViewById(R.id.headright_title_tv);
        tvLeft.setText("席位");
        tvCenter.setText("第一桌");
        tvRight.setText("");

        tvLeft.setOnClickListener(this);
        backLl.setOnClickListener(this);
        tvRight.setOnClickListener(this);
        overBtn.setOnClickListener(this);
        return myBodyView;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.headleft_title_iv:
                //返回
                CUtils.showToast("返回");
                mActivity.finish();
                break;
            case R.id.headright_title_tv:
                CUtils.showToast("over");
                //添加数据到服务器
                addData();
                mActivity.finish();
                break;
        }
    }

    public void addData() {
        String tableName = tablename_et.getText().toString();
        String customerName = message_et.getText().toString();
        String userUrl = UrlDealUtil.getRealUrl(RequestCode.ADD_TABLEINFO);
        User user = DataWareHourse.getInstance().getmUser();
        mobileNum = user.getData().get(0).getNvc_MobilePhone();
        userUrl += mobileNum;
        HashMap<String, String> mapData = new HashMap<String, String>();
        mapData.put("WeddingTableID", "tableID");
        mapData.put("TableName", tableName);
        mapData.put("MemberID", "numberID");
        mapData.put("CustomerName", customerName);
        mapData.put("PeopleNumber", "4");
        HttpRequestBean requestBean = new HttpRequestBean(RequestCode.POSTEQUEST, userUrl, this, CommonResultBean.class, RequestCode.ADD_TABLEINFO, mapData);
        XutilHttp taskHttp = new XutilHttp(mActivity, requestBean);
    }

    @Override
    public void onSucess(SuccessBean sucessbean) {

    }

    @Override
    public void onError(ErrorBean errorBean) {

    }
}
